class Torrent {
    def hasMany = [peers:Peer]
    Set peers
    String infoHash = ""
    String filename = ""
    Integer completed = 0

   Map stats() {
        def totalComplete = 0
        def totalIncomplete = 0
        peers.each{ peer.complete == 1 ? totalComplete++ : totalIncomplete++ }
        Map result = [ complete:totalComplete, incomplete:totalComplete]
        return result
    }
}
